var status = 0;
var random = java.lang.Math.floor(Math.random() * 4);
var eff = "#fEffect/CharacterEff/1082565/2/0#";
var vvv = "#fUI/Basic/BtHide3/mouseOver/0#";
var vvv4 = "#fUI/UIWindow4/PQRank/rank/gold#";
var z1 = "#fEffect/ItemEff/1112811/0/0#";//黄金音符
var z5 = "#fEffect/CharacterEff/1112904/2/1#";//五角花
cztp = 0;
function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (status == 0 && mode == 0) {
        cm.dispose();
        return;
    }
    if (mode == 1) {
        status++;
    } else {
        status--;
    }
    if (status == 0) {
        var txt = "\r\n#d┏━━━━━━━━━━挂机休闲中心━━━━━━━━━┓#k\r\n";
        //txt += "\t                 #r开服7天充值福利#k\r\n";
        //txt += "\t充值 [  50 ] - [  99 ] 元 #r ▲△ 赠予 20   余额#k\r\n";
        //txt += "\t充值 [ 100 ] - [ 199 ] 元 #r ▲△ 赠予 30  余额#k\r\n";
       // txt += "\t#b充值 [ 200 ] - [ 499 ] 元 #r ▲△ 赠予 80  余额#k\r\n";
       // txt += "\t#b充值 [ 500 以上不限  ] 元 #r ▲△ 赠予 双倍  余额#k\r\n";
        txt += "#d\t▲ 打发无聊挂机时间，让挂机变成一种娱乐 ▲\r\n";
        //txt += "#r\t▲ 充值比例 [ 1:1 ]#k[金额返利 充值方式返利] ▲\r\n";
        //txt += "#r\t             #L7#累计充值奖品系统#l\r\n";
        txt += "　#L1#" + vvv4 + " #r休闲零食专卖店#k#l　#L2#" + vvv4 + " #b优秀国产动漫#l\r\n";
        txt += "　#L3#" + vvv4 + " #b新番动画中心#k#l    #L4#" + vvv4 + " #bB站视频中心#k#l\r\n";
        txt += "  #L5#" + vvv4 + " #b最新电影中心#k#l    #L6#" + vvv4 + " #b网络小说排行#k#l\r\n";
        txt += "  #L7#" + vvv4 + " #b有声小说中心#k#l    #L8#" + vvv4 + " #b单机游戏排行#k#l\r\n\r\n";
        txt += "#d┗━━━━━━━━━━━━━━━━━━━━━━━━━┛#k\r\n\r\n";
        cm.sendSimple(txt);
    } else if (status == 1) {
        switch (selection) {
            case 0://抽奖
                cm.dispose();
                cm.sendOk("\r\n\r\n\t\t\t#e#r修复细节问题");
                //cm.openNpc(9900002, 17);
                break;
            case 1://充值
                cm.dispose();
                cm.sendOk("\r\n\r\n\t\t\t#e#r还没开");
                ////cm.openWeb("http://www.libaopay.com/buy/?wid=68597");
                break;
            case 8://充值
                cm.dispose();
                cm.sendOk("\r\n\r\n\t\t\t#e#r还没开");
                ////cm.openWeb("http://www.libaopay.com/buy/?wid=68597");
                break;
            case 2://累计充值
                cm.dispose();
                //cm.openWeb("http://list.iqiyi.com/www/4/37-------------4-1-1-iqiyi--.html");
                break;
            case 3://中介系统
                cm.dispose();
                //cm.openWeb("http://www.daman.cc/2016/");
                break;
            case 4://金额点卷
                cm.dispose();
                //cm.openWeb("http://www.bilibili.com/video/kichiku.html");
                break;
            case 5://充值礼包
                cm.dispose();
                //cm.openWeb("http://ly6080.com/?jumpTo=http%3A%2F%2Fwww.ly6080.com%2Fv.htm%3Fid%3D101");
                break;
            case 6://理财系统
                cm.dispose();
                //cm.openWeb("http://top.hengyan.com/");
                break;
            case 7://理财系统
                cztp = 2;
                var text = z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + "\r\n\r\n";
                text += "#d管管觉得好的有声小说推荐，希望宝宝能喜欢哦#l\r\n\r\n";
                text += "#b恐怖嫌疑类#l\r\n";
                text += "#r#L0#" + z5 + " 民调局异闻录 " + z5 + "#L1#" + z5 + " 民调局异闻录后传 " + z5 + "#l\r\n";
                text += "#r#L10#" + z5 + " 民调局异闻录前传 " + z5 + "#L11#" + z5 + " 民调局之暗夜将至 " + z5 + "#l\r\n\r\n";
				text += "#r#L2#" + z5 + " 十宗罪一 " + z5 + "#r#L3#" + z5 + " 十宗罪二 " + z5 + "#r#L4#" + z5 + " 十宗罪三 " + z5 + "#l\r\n";
				text += "#r#L5#" + z5 + " 十宗罪四 " + z5 + "#r#L6#" + z5 + " 十宗罪五 " + z5 + "#l\r\n\r\n";
				text += "#r#L7#" + z5 + " 摸金天师（活人回避）" + z5 + "#r#L8#" + z5 + "中国真实灵异事件 " + z5 + "#l\r\n\r\n";
				text += "#r#L9#" + z5 + " 有声小说网站 " + z5 + "#l\r\n\r\n";
				//text += "\t\t　#r#L5#" + z5 + " [ 10000] 累计豪礼 " + z5 + "#l\r\n\r\n";
                text += z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + z1 + "\r\n";
                cm.sendYesNoS(text, 2);
        }
    } else if (status == 2) {
        if (cztp == 1) {
            switch (selection) {
                case 0://金额充值点卷
                    if (cm.getHyPay(1) < 1) {
                        cm.sendOk("#r#e抱歉 ！您的金额数目 [0] 不能进行充值 ");
                        status = -1;
                    } else {
                        var revenue0 = cm.getHyPay(1);
                        cm.sendGetText("#r#e★★★★★★★★★『充值中心』★★★★★★★★★#d\r\n\r\n请入你需充值点卷的数量 [ 1：3000 ]\r\n\r\n当前 [ #r#h ##d ] 玩家持有金额：" + revenue0.formatMoney(0, "") + " 元\r\n\r\n#k ");
                    }
                    break;
            }
        }else   if (cztp == 2) {
            switch (selection) {
			            case 0://民调局异闻录
                cm.dispose();
                //cm.openWeb("http://www.ximalaya.com/1266964/album/351019");
                break;
			           case 1://民调局异闻录后传
                cm.dispose();
                //cm.openWeb("http://www.ximalaya.com/1266964/album/3936009");
                break;
				      case 2://十宗罪1
                cm.dispose();
                //cm.openWeb("http://www.ximalaya.com/41671068/album/5167193");
                break;
				      case 3://十宗罪2
                cm.dispose();
                //cm.openWeb("http://www.ximalaya.com/41671068/album/5209768");
                break;
				      case 4://十宗罪3
                cm.dispose();
                //cm.openWeb("http://www.ximalaya.com/41671068/album/5248995");
                break;
				      case 5://十宗罪4
                cm.dispose();
                //cm.openWeb("http://www.ximalaya.com/41671068/album/5279160");
                break;
				      case 6://十宗罪5
                cm.dispose();
                //cm.openWeb("http://www.520tingshu.com/book/book10497.html");
                break;
				      case 7://摸金天师（活人回避）
                cm.dispose();
                //cm.openWeb("http://www.ximalaya.com/1266964/album/4756811");
                break;
				      case 8://中国真实灵异事件
                cm.dispose();
                //cm.openWeb("http://www.ximalaya.com/10767650/album/3144814");
                break;
				      case 9://喜马拉雅
                cm.dispose();
                //cm.openWeb("http://www.ximalaya.com");
                break;
				      case 10://民调局异闻录前传
                cm.dispose();
                //cm.openWeb("http://www.ximalaya.com/10767650/album/3144814");
                break;
				      case 11://民调局之暗夜将至
                cm.dispose();
                //cm.openWeb("http://www.ximalaya.com/10767650/album/3144814");
                break;
				      case 12://50000
                cm.dispose();
                //cm.openWeb("http://www.ximalaya.com/10767650/album/3144814");
                break;
			}
		}
    } else if (status == 3) {
        if (cm.getHyPay(1) - cm.getText() < 0) {
            cm.sendOk("#r#e抱歉 ！充值后金额低于 [ 0 ] ");
            cm.dispose();
        } else {
            cm.addHyPay(+cm.getText());
            cm.gainNX(cm.getText() * 3000);
            cm.sendOk("#d#e恭喜您\r\n\r\n购买点卷数量：#r" + cm.getText() * 3000 + "#k#n\r\n ");
            cm.dispose();

        }
    }
}

Number.prototype.formatMoney = function (places, symbol, thousand, decimal) {
    places = !isNaN(places = Math.abs(places)) ? places : 2;
    symbol = symbol !== undefined ? symbol : "　";
    thousand = thousand || ",";
    decimal = decimal || ".";
    var number = this,
        negative = number < 0 ? "-" : "",
        i = parseInt(number = Math.abs(+number || 0).toFixed(places), 10) + "",
        j = (j = i.length) > 3 ? j % 3 : 0;
    return symbol + negative + (j ? i.substr(0, j) + thousand : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thousand) + (places ? decimal + Math.abs(number - i).toFixed(places).slice(2) : "");
};